/*****************************************************************************
 * Copyright (c) 2010 -, Anders All rights reserved
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 *  Contact: Anders Uddenberg (anders.uddenberg@gmail.com)
 * 
 *
 ****************************************************************************/
package org.easypr.organizer.client.view;

import org.easypr.organizer.client.presenter.RegisterPresenter;

import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

// TODO: Auto-generated Javadoc
/**
 * The Class RegisterView.
 */
public class RegisterView extends Composite implements RegisterPresenter.Display {

	/** The container. */
	FlowPanel container;
	
	/** The name input. */
	TextBox nameInput;
	
	/** The email label. */
	Label emailLabel;
	
	/** The cellphone input. */
	TextBox cellphoneInput;
	
	/** The workphone input. */
	TextBox workphoneInput;
	
	/** The workplace input. */
	TextBox workplaceInput;
	
	/** The save button. */
	Button saveButton;
	
	/** The logout link. */
	Anchor logoutLink;

	/**
	 * Instantiates a new menu view.
	 */
	public RegisterView() {
		container = new FlowPanel();
		initWidget(container);
		
		nameInput = new TextBox();
		emailLabel = new Label();
		cellphoneInput = new TextBox();
		workphoneInput = new TextBox();
		workplaceInput = new TextBox();
		saveButton = new Button("Register");
		logoutLink = new Anchor("Logout");
	}
	
	/* (non-Javadoc)
	 * @see org.easypr.organizer.client.presenter.RegisterPresenter.Display#getLogoutLink()
	 */
	public Anchor getLogoutLink() {
		return this.logoutLink;
	}
	
	/* (non-Javadoc)
	 * @see org.easypr.organizer.client.presenter.RegisterPresenter.Display#getNameInput()
	 */
	public TextBox getNameInput() {
		return this.nameInput;
	}
	
	/* (non-Javadoc)
	 * @see org.easypr.organizer.client.presenter.RegisterPresenter.Display#getEmailLabel()
	 */
	public Label getEmailLabel() {
		return this.emailLabel;
	}
	
	/* (non-Javadoc)
	 * @see org.easypr.organizer.client.presenter.RegisterPresenter.Display#getCellphoneInput()
	 */
	public TextBox getCellphoneInput() {
		return this.cellphoneInput;
	}
	
	/* (non-Javadoc)
	 * @see org.easypr.organizer.client.presenter.RegisterPresenter.Display#getWorkphoneInput()
	 */
	public TextBox getWorkphoneInput() {
		return this.workphoneInput;
	}
	
	/* (non-Javadoc)
	 * @see org.easypr.organizer.client.presenter.RegisterPresenter.Display#getWorkplaceInput()
	 */
	public TextBox getWorkplaceInput() {
		return this.workplaceInput;
	}
	
	/* (non-Javadoc)
	 * @see org.easypr.organizer.client.presenter.RegisterPresenter.Display#getSaveButton()
	 */
	public Button getSaveButton() {
		return this.saveButton;
	}
	
	/* (non-Javadoc)
	 * @see org.easypr.organizer.client.presenter.RegisterPresenter.Display#clearForm()
	 */
	public void clearForm() {
		nameInput.setText("Your name");
		//cellphoneInput.setText("Your cellphone number");
		//workphoneInput.setText("Your work phone number");
		workplaceInput.setText("Work place");
	}
	

	/* (non-Javadoc)
	 * @see org.easypr.organizer.client.presenter.RegisterPresenter.Display#setData(java.lang.String)
	 */
	public void setData(String email) {
		container.clear();

		HorizontalPanel header = new HorizontalPanel();
		header.setStyleName("content-header");
		
		FlowPanel body = new FlowPanel();
		body.setStyleName("content-body");

		Label lbl = new Label("Sign up");
		lbl.setStyleName("header-label");
		
		header.add(lbl);
		container.add(header);

		Label heading = new Label("Fill in your info or just click register (yes - it's that simple)");
		heading.addStyleName("heading");
		container.add(heading);
		
		
		FlexTable table = new FlexTable();
		
		
		table.getFlexCellFormatter().setColSpan(0, 0, 2);
		
		HorizontalPanel GoogleUserInfo = new HorizontalPanel();
		emailLabel.setWidth("100%");
		emailLabel.setText("Google user: " + email);
		GoogleUserInfo.setSpacing(4);
		GoogleUserInfo.add(emailLabel);
		GoogleUserInfo.add(logoutLink);
		
		table.setWidget(0, 0, GoogleUserInfo);
		

		table.getFlexCellFormatter().setColSpan(1, 0, 2);
		nameInput.setWidth("100%");
		table.setWidget(1, 0, nameInput);
		
		/*
		table.setWidget(2, 0, cellphoneInput);
		
		
		workphoneInput.setWidth("100%");
		table.setWidget(2, 1, workphoneInput);
		*/
		table.getFlexCellFormatter().setColSpan(3, 0, 2);
		workplaceInput.setWidth("100%");
		table.setWidget(3, 0, workplaceInput);
		
		table.setWidget(4, 0, saveButton);
		
		
		body.add(table);
		container.add(body);
		
		
	}

	/* (non-Javadoc)
	 * @see org.easypr.organizer.client.presenter.RegisterPresenter.Display#asWidget()
	 */
	@Override
	public Widget asWidget() {
		return this;
	}
}
